<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="/static/index/layui/css/layui.css">
		<link rel="stylesheet" href="/static/index/css/global.css">
		<script src="/static/index/layui/layui.js"></script>

    </head>

	<body>
		<iframe src="../head" scrolling="no" width="100%" height="65px"></iframe>
		<div class="main layui-clear">
		<div class="layui-container fly-marginTop">
			<div class="fly-panel fly-panel-user" pad20="">
				<div class="layui-tab layui-tab-brief" lay-filter="user">
					<ul class="layui-tab-title">
						<li>
							<a href="../log/login">登入</a>
						</li>
						<li class="layui-this">注册</li>
					</ul>
					<div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
						<div class="layui-tab-item layui-show">
							<div class="layui-form layui-form-pane">

								<form method="post" method="post" class="layui-form" onsubmit="return false" >
									<div class="layui-form-item">
										<label for="L_email" class="layui-form-label">用户名</label>
										<div class="layui-input-inline">
											<input type="text" id="userName" name="zz_name" placeholder="请输入用户名" required="" lay-verify="userName"  class="layui-input">
										</div>
										<div class="layui-form-mid layui-word-aux">
											将会成为您唯一的登入名
										</div>
									</div>


									<div class="layui-form-item">
										<label for="L_username" class="layui-form-label" >
											密码
										</label>
										<div class="layui-input-inline">
											<input type="password" id="name" placeholder="请输入密码" name="zz_pass" required="" lay-verify="required" autocomplete="off" class="layui-input">
										</div>
									</div>

									<div class="layui-form-item">
										<label for="L_username" class="layui-form-label" >
											二次密码
										</label>
										<div class="layui-input-inline">
											<input type="password" id="L_username" placeholder="再次输入密码" name="repass" required="" lay-verify="required" autocomplete="off" class="layui-input">
										</div>
									</div>

									<div class="layui-form-item">
										<label for="L_pass" class="layui-form-label">
											手机
										</label>
										<div class="layui-input-inline">
											<input maxlength="11" type="text" id="L_pass" placeholder="请输入手机号" name="zz_tel" required="" lay-verify="required" autocomplete="off" class="layui-input">
										</div>
									</div>

									<form>
										<div class="layui-form-item">

											<div class="layui-input-inline">
												<input type="text" id="L_usercode" placeholder="请输入验证码" name="code"  autocomplete="off" class="layui-input">
											</div>
                                            <button id="btn" class="layui-btn" lay-submit lay-filter="send">
                                                获取验证码
                                            </button>
										</div>
									</form>

									<div class="layui-form-item">
										<button class="layui-btn"  lay-submit lay-filter="zc">
											立即注册
										</button>
									</div>
                                </form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		</div>
	</body>
</html>
<script>
    layui.use('form', function(){
        $ = layui.jquery;
        var form = layui.form();

        //监听提交
        form.on('submit(send)', function(data){
            $.ajax({
                url:'../sendSms',
                type:'get',
                data:$('.layui-form').serialize(),
                success:function (data) {
                    console.log(data)
                    if (data) {
                        layer.msg("短信发送成功", {offset:'50%',icon: 6,time:500},function(){

                            var btn = document.getElementById('btn');
                            time = 360;

                            function timeButton() {
                                if ( time <= 0 ) {
                                    btn.disabled = false;
                                    btn.innerHTML = '获取验证码';
                                    btn.style.backgroundColor = '#009688';
                                    return;
                                }
                                btn.disabled = true;
                                btn.innerHTML = '已发送('+ time + ')';
                                btn.style.backgroundColor = '#ccc';
                                time--;
                                setTimeout(timeButton,1000);
                            }

                            timeButton();

                        });
                    } else {
                        layer.msg("短信发送失败", {offset:'50%',icon: 6,time:500}, function () {
                            x_admin_close();
                            parent.location.reload();
                        });
                    }
                }
            })

        });
    });

    layui.use('form', function(){
        $ = layui.jquery;
        var form = layui.form();
        console.log(form);

        //监听提交
        form.on('submit(zc)', function(data){
            $.ajax({
                url:'../doregister',
                type:'post',
                data:$('.layui-form').serialize(),
                dataType:'json',
                success:function (data) {
                    if (data.status) {
                        layer.msg("注册成功,请登陆", {offset:'50%',icon: 6,time:500},function(){
                            location.href='../log/login';
                        });
                    } else {
                        layer.msg("注册失败", {offset:'50%',icon: 6,time:500}, function () {
                            x_admin_close();
                            parent.location.reload();
                        });
                    }
                }
            })
        });
    });



</script>